import request from '../utils/request'

const baseUrl = 'save_connect'

export function importSaveConnectList(connectionList) {
    return request({
        url: baseUrl + '/importSaveConnectList',
        method: 'post',
        headers: {
            'Content-Type': 'application/json'
        },
        data: {connectionList}

    })
}

export function addConnection(connection, connectForm) {
    let data = connection
    data.groups = connectForm.groups
    data.name = connectForm.name
    return request({
        url: baseUrl + '/addSaveConnect',
        method: 'post',
        data: data
    })
}

export function addSaveConnectByConnectionId(connectForm, connectionId) {
    return request({
        url: baseUrl + '/addSaveConnectByConnectionId',
        method: 'post',
        data: {
            connectionId: connectionId,
            name: connectForm.name,
            groupId: connectForm.groups
        }
    })
}

export function editConnection(connection) {
    return request({
        url: baseUrl + '/editSaveConnect',
        method: 'post',
        data: connection
    })
}

export function editSaveConnectNameAndGroup(connection, connectionId) {
    let data = {
        name: connection.name,
        id: connection.id,
        groupId: connection.groups,
        connectionId: connectionId
    }
    return request({
        url: baseUrl + '/editSaveConnectNameAndGroup',
        method: 'post',
        data: data
    })
}

export function removeSaveConnects(ids) {
    return request({
        url: baseUrl + '/removeSaveConnects',
        method: 'post',
        data: {
            ids: ids.toString()
        }
    })
}

export function getAllSaveConnectList() {
    return request({
        url: baseUrl + '/getAllSaveConnectList',
        method: 'get',
        params: {}
    })
}